/*
 * @Author: 凉月 1931226988@qq.com
 * @Date: 2023-08-22 10:14:33
 * @LastEditors: 凉月 1931226988@qq.com
 * @LastEditTime: 2023-08-23 10:24:27
 * @FilePath: \v3_xmly\vite.config.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// 引入 path 来解析地址
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
    resolve: {
        alias: {
            "@": resolve(__dirname, "./src"),
        },
        extensions: [".ts", ".vue", ".js", ".jsx", ".tsx", ".mjs"], // 导入时想要省略的扩展名列表。
    },
    plugins: [
        vue(),

    ],
    server: {
        proxy: {
          // 带选项写法：http://localhost:5173/api/bar -> http://jsonplaceholder.typicode.com/bar
          "/api": {
            target: "https://m.ximalaya.com",
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ""),
          },
          "/login": {
            target: "http://sph-h5-api.atguigu.cn",
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/login/, ""),
          }
        },
    },
});
